<?php include template("header");?>

<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="content">
    <div id="deal-buy" class="box">
        <div class="box-top"></div>
        <div class="box-content">
            <div class="head"><h2>Seu pedido</h2></div>
            <div class="sect">
                <table class="order-table">
                    <tr>
                        <th class="deal-buy-desc">Oferta</th>
                        <th class="deal-buy-quantity">Quantidade</th>
                        <th class="deal-buy-multi"></th>
                        <th class="deal-buy-price">Preço</th>
                        <th class="deal-buy-equal"></th>
                        <th class="deal-buy-total">Total</th>
                    </tr>
                    <tr>
                        <td class="deal-buy-desc"><?php echo $team['title']; ?></td>
                        <td class="deal-buy-quantity"><?php echo $order['quantity']; ?></td>
                        <td class="deal-buy-multi">x</td>
                        <td class="deal-buy-price" id="deal-buy-price"><span class="money"><?php echo $currency; ?> <span><?php echo moneyit3($order['price']); ?></td>
                        <td class="deal-buy-equal">=</td>
                        <td class="deal-buy-total" id="deal-buy-total"><span class="money"><?php echo $currency; ?> </span><?php echo moneyit3($order['price']*$order['quantity']); ?></td>
                    </tr>
					<?php if($team['delivery']=='express'){?>
					<tr>
						<td class="deal-buy-desc">Dinheiro</td>
						<td class="deal-buy-quantity"></td>
						<td class="deal-buy-multi"></td>
						<td class="deal-buy-price"><span class="money"><?php echo $currency; ?> </span><span id="deal-express-price"><?php echo $team['fare']; ?></span></td>
						<td class="deal-buy-equal">=</td>
						<td class="deal-buy-total"><span class="money"><?php echo $currency; ?> </span><span id="deal-express-total"><?php echo ($team['farefree']==0||$order['quantity']<$team['farefree'])?$team['fare']:0; ?></span></td>
					</tr>
					<?php }?>
					<?php if($order['card']>0){?>
				   <tr id="cardcode-row">
						<td class="deal-buy-desc">Cupom de desconto:<span id="cardcode-row-n"><?php echo $order['card_id']; ?></span></td>
						<td class="deal-buy-quantity"></td>
						<td class="deal-buy-multi"></td>

						<td class="deal-buy-price"><span class="money"><?php echo $currency; ?> </span><?php echo moneyit3($order['card']); ?></td>
						<td class="deal-buy-equal">=</td>
						<td class="deal-buy-total">-<span class="money"><?php echo $currency; ?> </span><span id="cardcode-row-t"><?php echo moneyit3($order['card']); ?></span></td>
					</tr>
					<?php }?>

					<tr class="order-total">
                        <td class="deal-buy-desc"><strong>Total a ser pago: </strong></td>
                        <td class="deal-buy-quantity"></td>
                        <td class="deal-buy-multi"></td>
                        <td class="deal-buy-price"></td>
                        <td class="deal-buy-equal">=</td>
                        <td class="deal-buy-total"><span class="money"><?php echo $currency; ?></span><?php echo moneyit3($order['origin']); ?></td>
                    </tr>
                </table>
				<div class="paytype">
                <form action="/finalizar_compra" method="post" class="validator">
				<div class="order-check-form ">
					<div class="order-pay-credit">
						<h3>Saldo de sua conta</h3>
						<p>Balanço da conta:<strong><span class="money"><?php echo $currency; ?> </span><?php echo moneyit3($login_user['money']); ?></strong> <?php if(false==$credityes){?>. O saldo de sua conta é insuficiene para realizar o pagamento <strong><span class="money"><?php echo $currency; ?> </span><?php echo moneyit3($order['origin']-$login_user['money']); ?></strong>.<?php if($creditonly){?>Por favor faça <a href="/credit/charge.php">uma recarga de seus créditos</a>.<?php } else { ?>Por favor, escolha seu meio de pagamento:<?php }?><?php } else { ?>, O saldo de sua conta é suficiente para pagar este pedido. Por favor confirme o pedido.<?php }?></p>
						<div class="other_pay"><?php echo $INI['other']['pay']; ?></div>
					</div>

				<?php if(false==$creditonly && false==$credityes){?>
					<ul class="typelist">
					<?php if($INI['alipay']['mid']){?>
						<li><input id="check-alipay" type="radio" name="paytype" value="alipay" <?php echo $ordercheck['alipay']; ?> /><label for="check-alipay" class="alipay"></label></li>
					<?php }?>
					<?php if($INI['pagamentodg']['mid']){?>
						<li><input id="check-pagamentodg" type="radio" name="paytype" value="pagamentodg" <?php echo $ordercheck['pagamentodg']; ?> /><label for="check-pagamentodg" class="pagamentodg"></label></li>
					<?php }?>
					<?php if($INI['bill']['mid']){?>
						<li><input id="check-bill" type="radio" name="paytype" value="bill" <?php echo $ordercheck['bill']; ?> /><label for="check-bill" class="bill"></label></li>
					<?php }?>
					<?php if($INI['moip']['mid']){?>
						<li><input id="check-moip" type="radio" name="paytype" value="moip" <?php echo $ordercheck['moip']; ?> /><label for="check-moip" class="moip"></label></li>
					<?php }?>
					<?php if($INI['pagseguro']['mid']){?>
						<li><input id="check-pagseguro" type="radio" name="paytype" value="pagseguro" <?php echo $ordercheck['pagseguro']; ?> /><label for="check-pagseguro" class="pagseguro"></label></li>
					<?php }?>
					<?php if($INI['paypal']['mid']){?>
						<li><input id="check-paypal" type="radio" name="paytype" value="paypal" <?php echo $ordercheck['paypal']; ?> /><label for="check-paypal" class="paypal"></label></li>
					<?php }?>
					</ul>

				<?php } else { ?>
					<input type="hidden" name="paytype" value="credit" />
				<?php }?>

				<?php if($credityes || false==$creditonly){?>
					<div class="clear"></div>
					<p class="check-act">
					<input type="hidden" name="order_id" value="<?php echo $order['id']; ?>" />
					<input type="hidden" name="team_id" value="<?php echo $order['team_id']; ?>" />
					<input type="hidden" name="cardcode" value="" />
					<input type="hidden" name="quantity" value="<?php echo $order['quantity']; ?>" />
					<input type="hidden" name="address" value="<?php echo $order['address']; ?>" />
					<input type="hidden" name="express" value="<?php echo $order['express']; ?>" />
					<input type="hidden" name="remark" value="<?php echo $order['remark']; ?>" />
					<input type="submit" value="Finalizar compra" class="formbutton" />
					<?php if(false==$credityes){?>
					<input type="button" value="Voltar" class="formbutton" onclick="location.href='index.php';" />
					<?php }?>
					<a href="/<?php echo $city['ename']; ?>/comprar/<?php echo $order['team_id']; ?>" style="margin-left:1em;">Voltar para editar seu pedido</a>
				<?php }?>
					</p>
				</div>
				</form>
				</div>
			</div>
		</div>
		<div class="box-bottom"></div>
	</div>
</div>
<div id="sidebar">
<?php if(!$order['card_id']){?>
	<?php include template("block_side_card");?>
<?php }?>
</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->

<?php include template("footer");?>
